package com.ruoyi.Applet.controller.parts;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.ProductInfo;
import com.ruoyi.system.domain.vo.carInfo.CarSpellDictVo;
import com.ruoyi.system.domain.vo.eCatalog.ECatalogInfoListVo;
import com.ruoyi.system.domain.vo.eCatalog.ECatalogInfoVo;
import com.ruoyi.system.domain.vo.eCatalog.ECatalogVo;
import com.ruoyi.system.service.ICarInfoService;
import com.ruoyi.system.service.IProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @ClassName : ProductController
 * @Description :
 * @Author :
 * @Date: 2023-01-27 19:56
 */
@RestController
@RequestMapping("/applet/parts/productInfo")
public class ProductController extends BaseController {

    @Autowired
    private IProductInfoService productInfoService;

    /**
     * 查询电子目录
     */
    @PreAuthorize("@ss.hasPermi('system:carinfo:list')")
    @GetMapping("/getECatalog")
    public TableDataInfo getECatalog(ECatalogVo eCatalogVo)
    {
        startPage();
        List<ECatalogInfoVo> list = productInfoService.getECatalog(eCatalogVo);
        TableDataInfo dataTable = getDataTable(list);
        List<ECatalogInfoVo> rows = (List<ECatalogInfoVo>)dataTable.getRows();
        List<ECatalogInfoListVo> infoListVos = productInfoService.convertECatalog(rows);
        dataTable.setRows(infoListVos);
        return dataTable;
    }

    /**
     * 查询电子目录
     */
    @PreAuthorize("@ss.hasPermi('system:carinfo:list')")
    @GetMapping("/getECatalogDict")
    public AjaxResult getECatalogDict(ECatalogVo eCatalogVo)
    {
//        startPage();
        Map<String,Object> map = productInfoService.getECatalogDict(eCatalogVo);
        return success(map);
    }
}
